/**
* @Description: 供应商查询-详情
* @author  tangbin
* @date 2023/4/18
*/
<template>
  <div class="mh100">
    <div class="page-container">

      <div class="split-content-info" :style="{minHeight: height + 'px'}">
        <!-- 标题 -->
        <div class="split-content-title clearfix">
          <div class="split-title">
            <span style="display:inline-block; background-color: #1890FF;margin-bottom: -2px; margin-right: 8px; width: 3px; height: 14px"></span>
            <span style="display: inline-block; color: #333333; font-size: 16px;">基本信息</span>
          </div>
        </div>
        <div>
          <el-descriptions class="margin-top" :column="3" border>
            <el-descriptions-item labelStyle="width: 150px" contentStyle="width: 250px" label="渠道名称">{{ form.customerTenantName }}</el-descriptions-item>
            <el-descriptions-item labelStyle="width: 150px" contentStyle="width: 250px" label="供应商编码">{{ form.code }}</el-descriptions-item>
            <el-descriptions-item labelStyle="width: 150px" contentStyle="width: 250px" label="供应商名称">{{ form.name }}</el-descriptions-item>
            <el-descriptions-item label="供应商类型">{{ getSupplierTypeName(form.supplierType) }}</el-descriptions-item>
            <el-descriptions-item label="地区">{{ form.areaName }}</el-descriptions-item>
            <el-descriptions-item label="公司地址">{{ form.companyAddress }}</el-descriptions-item>
            <el-descriptions-item label="联系地址">{{ form.contactAddress }}</el-descriptions-item>
            <el-descriptions-item label="公司电话">{{ form.companyMobile }}</el-descriptions-item>
            <el-descriptions-item label="联系人">{{ form.contactName }}</el-descriptions-item>
            <el-descriptions-item label="联系电话">{{ form.contactMobile }}</el-descriptions-item>
            <el-descriptions-item label="供应商状态">{{ getSupplierStatusName(form.status) }}</el-descriptions-item>
            <el-descriptions-item label=""></el-descriptions-item>
            <el-descriptions-item label="备注">{{ form.remark }}</el-descriptions-item>
          </el-descriptions>
        </div>
      </div>


      <div class="h84_line"></div>
      <div class="bottom-btn">
        <div class="bottom-locate" >
          <el-button type="primary" @click="cancel">返回</el-button>
        </div>
      </div>

    </div>
  </div>
</template>


<script>
import {getTimeSeconds} from '@/utils/index.js'

export default {
  name: 'SupplierQueryDetail',
  dicts: ['supplier_type', 'supplier_status'], // 供应商类型 供应商状态
  data() {
    return {
      id: this.$route.query.id,
      
      mountedTime: undefined, // mounted时间
      activatedTime: undefined, // activated时间
      height: 626,
      saveloading: false, // 点击确认旋转轮
      form: JSON.parse(this.$route.query.info),
    }
  },
  mounted() {
    this.mountedTime = new Date();
    this.id = this.$route.query.id;
    this.form = JSON.parse(this.$route.query.info);
    // this.getCustomerGoodsDetail();
    // 解决表格设置固定高度导致列设置fixed后重新进来会错行问题
    this.tableHeight();
  },
  activated() {
    this.activatedTime = new Date();
    let isNew = false; // 默认不是新的
    if (this.id !== this.$route.query.id) {
      isNew = true; // 新的
    }
    this.id = this.$route.query.id;
    this.form = JSON.parse(this.$route.query.info);
    let seconds = getTimeSeconds(this.mountedTime, this.activatedTime);
    if (seconds >= 1 && isNew) {
      // this.getCustomerGoodsDetail();
    }
    // 解决表格设置固定高度导致列设置fixed后重新进来会错行问题
    this.tableHeight();
  },
  methods: {
    tableHeight() {
      this.$nextTick(() => {
        let height = document.body.clientHeight - 90 - 40;// - 62 - 20;
        // 查询表单高度
        let s_height = 0;
        // 按钮容器高度
        // let btns_height = document.getElementById('comTabel').clientHeight;
        // 计算表格的高度
        this.height = height - s_height - 20 - 44;
      });
    },


    cancel() {
      const obj = { path: "/basicData/supplierQuery" };
      this.$tab.closeOpenPage(obj);
    },

    /**
     * 得到供应商类型名称
     * @param {*} value 
     */
    getSupplierTypeName(value) {
      let show = value;
      this.dict.type.supplier_type.some((item) => {
        if (item.value === value) {
          show = item.label;
          return true;
        }
      });
      return show;
    },

    /**
     * 得到供应商状态名称
     * @param {*} value 
     */
    getSupplierStatusName(value) {
      let show = value;
      this.dict.type.supplier_status.some((item) => {
        if (item.value === value) {
          show = item.label;
          return true;
        }
      });
      return show;
    },

  },
}
</script>

<style lang="scss" scoped>
</style>